/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mekegi.whoanthro.Sql;

import android.content.ContentValues;
import android.content.Context;
import com.mekegi.whoanthro.Child;
import com.mekegi.whoanthro.ModelBuilder;
import com.mekegi.whoanthro.R;

/**
 *
 * @author Arsen Abdusalamov
 */
public class ChildAdapter extends AbstractSqlAdapter {

    protected static int DB_VERSION = 1;
    protected static final String[] COLUMNS_TO_TAKE = {
        Child.KEY_ID,
        Child.KEY_FIRST_NAME,
        Child.KEY_LAST_NAME,
        Child.KEY_OTHER_NAME,
        Child.KEY_BIRTHDAY
    };
    protected static int LAYOUT_ID = R.layout.childs;
    protected static int MODEL_KEY_FOR_FACTORY = ModelBuilder.MODEL_CHILD;
    protected static ContentValues config;

    public ChildAdapter(Context context) {
        super(context);
    }

    @Override
    protected String getCreateTableSql() {
        return "CREATE TABLE " + getTableName() + "("
            + Child.KEY_ID + " INTEGER NOT NULL,"
            + Child.KEY_FIRST_NAME + " VARCHAR(255) NOT NULL,"
            + Child.KEY_LAST_NAME + " VARCHAR(255),"
            + Child.KEY_OTHER_NAME + " VARCHAR(255),"
            + Child.KEY_BIRTHDAY + " INTEGER,"
            + "PRIMARY KEY (" + Child.KEY_ID + ")"
            + ")";
    }

    @Override
    protected ContentValues getConfigMap() {
        if (null == config) {
            config = new ContentValues();
            config.put(KEY_DB_VERSION, DB_VERSION);
            config.put(KEY_LAYOUT_ID, LAYOUT_ID);
            config.put(KEY_MODEL_FOR_FACTORY, MODEL_KEY_FOR_FACTORY);
            config.put(KEY_TABLE_NAME, Child.TABLE_NAME);
        }
        return config;
    }

    @Override
    protected String[] getColumnsToTake() {
        return COLUMNS_TO_TAKE;
    }
}
